const Util = {
	// 时间格式化
	formatTime(leftTime) {
		var leftTime = new Date(leftTime) - new Date() //计算剩余的毫秒数
		var days = parseInt(leftTime / 1000 / 60 / 60 / 24, 10) //计算剩余的天数
		var hours = parseInt((leftTime / 1000 / 60 / 60) % 24, 10) //计算剩余的小时
		var minutes = parseInt((leftTime / 1000 / 60) % 60, 10) //计算剩余的分钟
		var seconds = parseInt((leftTime / 1000) % 60, 10) //计算剩余的秒数
		days = this.checkTime(days)
		hours = this.checkTime(hours)
		minutes = this.checkTime(minutes)
		seconds = this.checkTime(seconds)

		let timer = `${days}天${hours}小时${minutes}分${seconds}秒`
		return timer
	},
	checkTime(i) {
		//将0-9的数字前面加上0，例1变为01
		if (i < 10) {
			i = '0' + i
		}
		return i
	},
}
export {Util}
